
let template = (option) => {
  let { label, prop, formName } = option
  let t = `<el-col :span="span">
        <el-form-item label="${label}" prop="${prop}">
          <el-input v-model="${formName}.${prop}"></el-input>
        </el-form-item>
      </el-col>`
  return t
}

const make = (form, formName = 'form', rulesName = 'rules') => {
  let f = ''
  for (const key in form) {
    let option = {}
    option.prop = key
    option.label = form[key].label
    option.formName = formName
    option.rulesName = rulesName
    f += template(option)
  }
  return `<el-form :model="${formName}" :rules="${rulesName}">
    <el-row :gutter="20">
      ${f}
    </el-row>
  </el-form>`
}

export default make

// let _main = () => {
//   const fs = require("fs");
//   let str = make(form)
//   fs.writeFileSync("form.vue", str, {
//     encoding: "utf8",
//   });
// }

// _main()
